package movee.spring.app.template.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 *
 *
 * @author movee
 */
@Getter
@AllArgsConstructor
public enum InterfaceType {

    PHYSICAL(1, "physical", "physical port"),
    VLAN(2, "vlan", "vlan port"),
    AGGREGATOR(3, "aggregator", "aggregator port"),
    TUNNEL(4, "tunnel", "tunnel port"),
    LOOPBACK(5, "loopback", "loopback port"),
    MANAGE(6, "management", "management port"),
    MPLS(7, "mpls", "mpls tunnel port"),
    OTHER(8, "other", "other");

    int id;
    String name;
    String description;

    private static final Map<String, InterfaceType> MAP = new HashMap<>();

    static {
        for (InterfaceType context : InterfaceType.values()) {
            MAP.put(context.getName(), context);
        }
    }

    /**
     * 从名字映射到类型
     * @param value
     * @return
     */
    public static InterfaceType fromName(String value) {
        return MAP.get(value);
    }

}

